window.onload = function(){
	document.getElementById("username").onblur = function(){
		var user = this.value;
		
		var userExp = /^[a-zA-Z]\w{5,}$/;
		if(false == userExp.test(user)){
			document.getElementById("userTip").innerHTML = "用户名由字母数字组成，且由字母开头，长度至少六位";
			//this.focus();
		}
		else{
			document.getElementById("userTip").innerHTML = "";
		}
	}
	document.getElementById("password").onblur = function(){
		var pwd = this.value;
		var pwdExp = /^\w{8,}$/;
		
		if(false == pwdExp.test(pwd)){
			document.getElementById("pswdTip").innerHTML = "密码至少8位字符";
			//this.focus();
		}
		else{
			document.getElementById("pswdTip").innerHTML = '';
		}
	}
	
	document.getElementById("password2").onblur = function(){
		var repwd = this.value;
		var pwd = document.getElementById("password").value;
		
		if(pwd != repwd){
			document.getElementById("pswd2Tip").innerHTML = "两次输入密码不一致";
			//this.focus();
		}
		else{
			document.getElementById("pswd2Tip").innerHTML = "";
		}
	}
	
	document.getElementById("email").onblur = function(){
		var email = this.value;
		
		var emailExp = /^\w+@\w+\.\w+$/;
		if(false == emailExp.test(email)){
			document.getElementById("emailTip").innerHTML = "请输入正确的邮箱地址";
			//this.focus();
		}
		else{
			document.getElementById("emailTip").innerHTML = "";
		}
	}
	
	document.getElementById("captchaImg").onclick = function(){
		this.src = "createImg.php?"+Math.random();
	}
}
